package com.AAA.service.Impl.scl;

import com.AAA.entity.MyPage;
import com.AAA.entity.scl.TSclPlane;
import com.AAA.service.scl.TSclPlaneService;
import com.AAA.dao.scl.TSclPlaneMapper;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * (TSclPlane)表服务实现类
 *
 * @author makejava
 * @since 2022-10-28 17:00:23
 */
@Service
public class TSclPlaneServiceImpl implements TSclPlaneService {
   @Autowired
   private TSclPlaneMapper tSclPlaneDao;

   @Override
   public PageInfo queryAll(MyPage myPage, TSclPlane tSclPlane){
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      return new PageInfo(tSclPlaneDao.selectAllData(tSclPlane));
   }

   @Override
   public boolean selectPlane(TSclPlane plane) {
      List<TSclPlane> select = tSclPlaneDao.select(plane);
      return select.size()==0?true:false;
   }

   @Override
   public boolean insertPlane(TSclPlane plane) {
      int insert=-1;
      System.out.println(plane.getId());
      if (plane.getId()==null) {
         insert = tSclPlaneDao.insert(plane);
      }else {
         plane.setUpdatetime(new Date());
         insert = tSclPlaneDao.updateByPrimaryKeySelective(plane);

      }

      return insert > 0 ? true : false;
   }

   @Override
   public TSclPlane queryByQyCode(TSclPlane tSclPlane) {
      TSclPlane tSclPlane1 = tSclPlaneDao.selectOne(tSclPlane);
      return tSclPlane1;
   }

   @Override
   public boolean updatas(TSclPlane tSclPlane) {
      int i = tSclPlaneDao.updateByPrimaryKeySelective(tSclPlane);
      return i>0?true:false;
   }
}
